package com.wsj.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.wsj.dao.IDirectSeedClassDao;
import com.wsj.service.IDirectSeedClassServ;
import com.wsj.util.exception.BusinessException;
import com.wsj.util.page.PageResultSet;
import com.wsj.web.vo.homeSite.DirectSeedClass;

public class DirectSeedClassServImpl implements IDirectSeedClassServ {

	private IDirectSeedClassDao directSeedClassDao;
	
	
	public void add(DirectSeedClass directSeedClass) throws BusinessException {
		this.directSeedClassDao.add(directSeedClass);
		directSeedClass.setSequence(directSeedClass.getId());
		this.directSeedClassDao.update(directSeedClass);
	}

	public void del(DirectSeedClass directSeedClass) throws BusinessException {
		this.directSeedClassDao.del(directSeedClass);
	}

	public void update(DirectSeedClass directSeedClass)	throws BusinessException {
		this.directSeedClassDao.update(directSeedClass);
	}
	
	public DirectSeedClass loadById(Integer id) throws BusinessException {
		return	this.directSeedClassDao.loadById(id);
	}

	public List<DirectSeedClass> loadByNameId(Integer directSeedNameId)	throws BusinessException {
		return this.directSeedClassDao.loadByNameId(directSeedNameId);
	}

	
	//  判断栏目名是否被占用 true 被占用
	public boolean checkName(String lanmuname, Integer directSeedNameId) throws BusinessException {
		DirectSeedClass directSeedClass = this.directSeedClassDao.loadByNameAndNameId(lanmuname, directSeedNameId);
		if(directSeedClass!=null){
			return true;
		}
		return false;
	}

	public Map<String, String> loadByNameIdMap(Integer directSeedNameId) throws BusinessException {
		
		Map<String, String> map=new HashMap<String, String>();
		
		List list=this.directSeedClassDao.loadByNameId(directSeedNameId);
		if(list!=null&&!list.isEmpty()){
			for(int i=0;i<list.size();i++){
				DirectSeedClass directSeedClass=(DirectSeedClass) list.get(i);
				
				if(directSeedClass!=null){
					map.put(directSeedClass.getId().toString(), directSeedClass.getLanmuname());
					
				}
			}
		}
		return map;
	}

	
	/**
	 * 分页查询：
	 * 条件：直播名ID、栏目名、是否删除、是否推荐、开始时间、结束时间
	 * 返回：MagazineClass  列表集合
	 * */
	public PageResultSet loadPageList(Integer nameId, String lanmuname,
			Short iftj, Short shanchu, String beginDate, String endDate,
			Integer page, Integer pageSize) throws BusinessException {
		return this.directSeedClassDao.loadPageList(nameId, lanmuname, iftj, shanchu, beginDate, endDate, page, pageSize);
	}

	
	public IDirectSeedClassDao getDirectSeedClassDao() {
		return directSeedClassDao;
	}

	public void setDirectSeedClassDao(IDirectSeedClassDao directSeedClassDao) {
		this.directSeedClassDao = directSeedClassDao;
	}

	public DirectSeedClass getDirectSeedClassBylanmuname(String directSeedClass_scdt) throws BusinessException {
		// TODO Auto-generated method stub
		
		DirectSeedClass directSeedClass=this.directSeedClassDao.getDirectSeedClassBylanmuname(directSeedClass_scdt);
		return directSeedClass;
	}

	public List getDirectSeedClassByParentId(Integer id) throws BusinessException {
		// TODO Auto-generated method stub
		
		List list=this.directSeedClassDao.getDirectSeedClassByParentId(id);
		
		return list;
	}

		
}










